﻿Shader "Lch/PlaneShader"
{
    Properties
    {
		_Color("Main Color", Color) = (0,0,0,0.5)
        //_MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
			Blend SrcAlpha OneMinusSrcAlpha
			ZWrite Off
			//ZTest Always
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            
    

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                //float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                //UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            //sampler2D _MainTex;
            //float4 _MainTex_ST;
			float4 _Color;
            v2f vert (appdata v)
            {
                v2f o;
				 
				float worldBase =  mul(unity_ObjectToWorld, float4(0,0,0, 1.0)).y;
				float4 wpos = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0));
				
				//wpos  + _WorldSpaceLightPos0.xyz*t = ground;
				//ground.Y = worldBase;
				//t = (worldBase-wpos.y)/_WorldSpaceLightPos0.y;
				float t = (worldBase -wpos.y) / _WorldSpaceLightPos0.y;
				wpos.xyz = wpos.xyz + _WorldSpaceLightPos0.xyz*t;
                o.vertex =  mul(UNITY_MATRIX_VP, wpos);
                //o.uv = TRANSFORM_TEX(v.uv, _MainTex);
 
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
				return _Color;
            }
            ENDCG
        }
    }
}
